import { inject, Injectable } from '@angular/core';
import { delay, Observable, of } from 'rxjs';

import { MENU_TOKEN } from '@config/menu';
import { Menu } from '@core/services/types';
import { BaseHttpService } from '@services/base-http.service';
// import { MenusService } from '@services/system/menus.service';

export interface UserLogin {
  userName: string;
  password: string;
}

@Injectable({
  providedIn: 'root'
})
export class LoginService {
  http = inject(BaseHttpService);
  private menus = inject(MENU_TOKEN);

  public login(params: UserLogin): Observable<string> {
    //模拟返回token
    return of('token');
  }

  public loginOut(): Observable<string> {
    return this.http.post('/auth/signout', null, { needSuccessInfo: false });
  }

  public getMenuByUserAuthCode(): Observable<Menu[]> {
    return of(this.menus).pipe(delay(1));
  }
}
